package com.youyi.yyfilepickerlibrary.SDK;

import android.content.Context;
import android.content.Intent;
import java.util.ArrayList;
import java.util.List;

public class YYPickSDK {
    public static boolean isAll = false;
    public static OnFolderListener mOnFolderListener;
    public static OnPickListener mOnPickListener;
    private static final YYPickSDK ourInstance = new YYPickSDK();
    private Context mContext;
    private Intent mIntent;

    public interface OnFolderListener {
        void result(boolean z, String str, String str2);
    }

    public interface OnPickListener {
        void result(boolean z, String str, List<String> list);
    }

    public enum PicEnum {
        file,
        filelist,
        media,
        pic,
        folder
    }

    public static YYPickSDK getInstance(Context context) {
        YYPickSDK yYPickSDK = ourInstance;
        yYPickSDK.initContext(context);
        return yYPickSDK;
    }

    private void initContext(Context context) {
        this.mContext = context;
    }

    private YYPickSDK() {
    }

    public void choseFile(String str, int i, boolean z, OnPickListener onPickListener) {
        isAll = false;
        mOnPickListener = onPickListener;
        Intent intent = new Intent(this.mContext, YYPickActivity.class);
        this.mIntent = intent;
        intent.putExtra("fileEndName", str);
        this.mIntent.putExtra("num", i);
        this.mIntent.putExtra("isFoldType", z);
        this.mIntent.putExtra("PicEnum", PicEnum.file.toString());
        this.mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        this.mContext.startActivity(this.mIntent);
    }

    public void choseFileList(int i, boolean z, OnPickListener onPickListener, String... strArr) {
        isAll = false;
        mOnPickListener = onPickListener;
        Intent intent = new Intent(this.mContext, YYPickActivity.class);
        this.mIntent = intent;
        intent.putExtra("fileEndNames", strArr);
        this.mIntent.putExtra("num", i);
        this.mIntent.putExtra("isFoldType", z);
        this.mIntent.putExtra("PicEnum", PicEnum.filelist.toString());
        this.mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        this.mContext.startActivity(this.mIntent);
    }

    public void choseFileListOfAllType(int i, boolean z, OnPickListener onPickListener) {
        isAll = true;
        mOnPickListener = onPickListener;
        FileTypeEnum[] values = FileTypeEnum.values();
        ArrayList arrayList = new ArrayList();
        for (FileTypeEnum fileTypeEnum : values) {
            arrayList.add(fileTypeEnum.getEndName());
        }
        Intent intent = new Intent(this.mContext, YYPickActivity.class);
        this.mIntent = intent;
        intent.putExtra("num", i);
        this.mIntent.putExtra("fileEndNames", (String[]) arrayList.toArray(new String[arrayList.size()]));
        this.mIntent.putExtra("isFoldType", z);
        this.mIntent.putExtra("PicEnum", PicEnum.filelist.toString());
        this.mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        this.mContext.startActivity(this.mIntent);
    }

    public void choseMedia(int i, OnPickListener onPickListener) {
        isAll = false;
        mOnPickListener = onPickListener;
        Intent intent = new Intent(this.mContext, YYPickActivity.class);
        this.mIntent = intent;
        intent.putExtra("num", i);
        this.mIntent.putExtra("PicEnum", PicEnum.media.toString());
        this.mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        this.mContext.startActivity(this.mIntent);
    }

    public void chosePic(int i, OnPickListener onPickListener) {
        isAll = false;
        mOnPickListener = onPickListener;
        Intent intent = new Intent(this.mContext, YYPickActivity.class);
        this.mIntent = intent;
        intent.putExtra("num", i);
        this.mIntent.putExtra("PicEnum", PicEnum.pic.toString());
        this.mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        this.mContext.startActivity(this.mIntent);
    }

    public void choseFolder(OnFolderListener onFolderListener) {
        isAll = false;
        mOnFolderListener = onFolderListener;
        Intent intent = new Intent(this.mContext, YYPickActivity.class);
        this.mIntent = intent;
        intent.putExtra("PicEnum", PicEnum.folder.toString());
        this.mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        this.mContext.startActivity(this.mIntent);
    }
}
